package com.kky.pp.base

import android.os.Bundle
import android.view.View
import com.custom.base.mvp.BasePresenterImpl
import com.kky.pp.util.SoftInputUtils
import io.rong.imkit.utils.StatusBarUtil

open class TitleBasePresenterImpl<V : TitleBaseView> : BasePresenterImpl<V>(),
    TitleBasePresenter<V> {
    override fun initBundle(bundle: Bundle) {
        mView?.apply {
            if (getTitle.isNotEmpty())
                tvMiddleTitle?.text = getTitle
            if (getLeftResID != 0)
                ivLeftImage?.setImageResource(getLeftResID)
            ivLeftImage?.setOnClickListener {
                SoftInputUtils.hideSoftInput(ivLeftImage)
                onBackClick()
            }
            ivLeftImage?.visibility = if (showBack) View.VISIBLE else View.INVISIBLE
            val params = viewStatusHeight?.layoutParams
            params?.height = StatusBarUtil.getStatusBarHeight(mActivity)
            viewStatusHeight?.layoutParams = params
        }
    }

    open fun onBackClick(){}
}